using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PACKETPARSERMAX20.CORE;

namespace PACKETPARSERMAX20.CORE.DEFINITIONS
{
    public class SMSG_SPELLLOGEXECUTE_DEF : DefinitionBase
    {
        public override bool Process()
        {
            ResetPosition();
            ulong guid = popGuid();

            UInt32 m_spellInfoId = ReadUInt32();

            UInt32 count1 = ReadUInt32();                                 // count1 (effect count?)
            for (int i = 0; i < count1; ++i)
            {
                SpellEffects m_spellInfoEffect = (SpellEffects)ReadUInt32();                // spell effect
                UInt32 count2 = ReadUInt32();                             // count2 (target count?)
                ulong guid2 = 0;
                for (int j = 0; j < count2; ++j)
                {
                    switch (m_spellInfoEffect)
                    {
                        case SpellEffects.SPELL_EFFECT_POWER_DRAIN:
                            guid2 = popGuid();
                            UInt32 uint_1 = ReadUInt32();
                            UInt32 uint_2 = ReadUInt32();
                            float float_1 = ReadSingle();
                            break;
                        case SpellEffects.SPELL_EFFECT_ADD_EXTRA_ATTACKS:
                            guid2 = popGuid();
                            UInt32 count3 = ReadUInt32();                      // count?
                            break;
                        case SpellEffects.SPELL_EFFECT_INTERRUPT_CAST:
                            guid2 = popGuid();
                            UInt32 spellid = ReadUInt32();                      // spellid
                            break;
                        case SpellEffects.SPELL_EFFECT_DURABILITY_DAMAGE:
                            guid2 = popGuid();
                            UInt32 uint_3 = ReadUInt32();
                            UInt32 uint_4 = ReadUInt32();
                            break;
                        case SpellEffects.SPELL_EFFECT_OPEN_LOCK:
                            guid2 = popGuid();
                            break;
                        case SpellEffects.SPELL_EFFECT_CREATE_ITEM:
                        case SpellEffects.SPELL_EFFECT_CREATE_ITEM_2:
                            UInt32 EffectItemType = ReadUInt32();
                            break;
                        case SpellEffects.SPELL_EFFECT_SUMMON:
                        case SpellEffects.SPELL_EFFECT_TRANS_DOOR:
                        case SpellEffects.SPELL_EFFECT_SUMMON_PET:
                        case SpellEffects.SPELL_EFFECT_SUMMON_OBJECT_WILD:
                        case SpellEffects.SPELL_EFFECT_CREATE_HOUSE:
                        case SpellEffects.SPELL_EFFECT_DUEL:
                        case SpellEffects.SPELL_EFFECT_SUMMON_OBJECT_SLOT1:
                        case SpellEffects.SPELL_EFFECT_SUMMON_OBJECT_SLOT2:
                        case SpellEffects.SPELL_EFFECT_SUMMON_OBJECT_SLOT3:
                        case SpellEffects.SPELL_EFFECT_SUMMON_OBJECT_SLOT4:
                            if (AvailableBytes > 0)
                                guid2 = popGuid();                   // guid
                            break;
                        case SpellEffects.SPELL_EFFECT_FEED_PET:
                            UInt32 ItemTargetEntry = ReadUInt32();
                            break;
                        case SpellEffects.SPELL_EFFECT_DISMISS_PET:
                            guid2 = popGuid();
                            break;
                        case SpellEffects.SPELL_EFFECT_RESURRECT:
                        case SpellEffects.SPELL_EFFECT_RESURRECT_NEW:
                            guid2 = popGuid();
                            break;
                        case SpellEffects.SPELL_EFFECT_CREATE_RANDOM_ITEM:
                            UInt32 itemid = ReadUInt32();
                            break;
                        default:
                            break;
                    }
                }
            }

            return Validate();
        }

        //public bool Process_()
        //{
        //    ResetPosition();

        //    ulong Caster_or_Targer_Guid = popGuid();
        //    uint spellInfoId = ReadUInt32();

        //    UInt32 count1 = ReadUInt32(); // count1 (effect count?)
        //    for (int i = 0; i < count1; ++i)
        //    {
        //        SpellEffects spellInfoEffect = (SpellEffects)ReadUInt32();          // spell effect?
        //        UInt32 count2 = ReadUInt32();                             // count2 (target count?)
        //        for (int j = 0; j < count2; ++j)
        //        {

        //            switch (spellInfoEffect)
        //            {
        //                case SpellEffects.SPELL_EFFECT_POWER_DRAIN:

        //                    ulong AUnitTargetGuid = popGuid();

        //                    UInt32 aa = ReadUInt32();
        //                    UInt32 ba = ReadUInt32();
        //                    float ca = ReadSingle();
        //                    break;
        //                case SpellEffects.SPELL_EFFECT_ADD_EXTRA_ATTACKS:
        //                    ulong BUnitTargetGuid = popGuid();
        //                    UInt32 count = ReadUInt32();                      // count?
        //                    break;
        //                case SpellEffects.SPELL_EFFECT_INTERRUPT_CAST:
        //                    ulong CUnitTargetGuid = popGuid();
        //                    UInt32 spellid = ReadUInt32();                      // spellid
        //                    break;
        //                case SpellEffects.SPELL_EFFECT_DURABILITY_DAMAGE:
        //                    ulong DUnitTargetGuid = popGuid();
        //                    UInt32 ab = ReadUInt32();
        //                    UInt32 bb = ReadUInt32();
        //                    break;
        //                case SpellEffects.SPELL_EFFECT_OPEN_LOCK:
        //                case SpellEffects.SPELL_EFFECT_OPEN_LOCK_ITEM:
        //                    ulong ItemTargetGuid = popGuid();
        //                    break;
        //                case SpellEffects.SPELL_EFFECT_CREATE_ITEM:
        //                    UInt32 EffectItemType = ReadUInt32();
        //                    break;
        //                case SpellEffects.SPELL_EFFECT_SUMMON:
        //                case SpellEffects.SPELL_EFFECT_SUMMON_WILD:
        //                case SpellEffects.SPELL_EFFECT_SUMMON_GUARDIAN:
        //                case SpellEffects.SPELL_EFFECT_TRANS_DOOR:
        //                case SpellEffects.SPELL_EFFECT_SUMMON_PET:
        //                case SpellEffects.SPELL_EFFECT_SUMMON_POSSESSED:
        //                case SpellEffects.SPELL_EFFECT_SUMMON_TOTEM:
        //                case SpellEffects.SPELL_EFFECT_SUMMON_OBJECT_WILD:
        //                case SpellEffects.SPELL_EFFECT_CREATE_HOUSE:
        //                case SpellEffects.SPELL_EFFECT_DUEL:
        //                case SpellEffects.SPELL_EFFECT_SUMMON_TOTEM_SLOT1:
        //                case SpellEffects.SPELL_EFFECT_SUMMON_TOTEM_SLOT2:
        //                case SpellEffects.SPELL_EFFECT_SUMMON_TOTEM_SLOT3:
        //                case SpellEffects.SPELL_EFFECT_SUMMON_TOTEM_SLOT4:
        //                case SpellEffects.SPELL_EFFECT_SUMMON_PHANTASM:
        //                case SpellEffects.SPELL_EFFECT_SUMMON_CRITTER:
        //                case SpellEffects.SPELL_EFFECT_SUMMON_OBJECT_SLOT1:
        //                case SpellEffects.SPELL_EFFECT_SUMMON_OBJECT_SLOT2:
        //                case SpellEffects.SPELL_EFFECT_SUMMON_OBJECT_SLOT3:
        //                case SpellEffects.SPELL_EFFECT_SUMMON_OBJECT_SLOT4:
        //                case SpellEffects.SPELL_EFFECT_SUMMON_DEMON:
        //                case SpellEffects.SPELL_EFFECT_150:
        //                    //Unit, Item or GO GUID
        //                    ulong TargetGuid = popGuid();
        //                    break;
        //                case SpellEffects.SPELL_EFFECT_FEED_PET:
        //                    UInt32 ItemTargetEntry = ReadUInt32();
        //                    break;
        //                case SpellEffects.SPELL_EFFECT_DISMISS_PET:
        //                    ulong EUnitTargetGuid = popGuid();
        //                    break;
        //                default:
        //                    break;
        //            }
        //        }
        //    }

        //    return Validate();
        //}
    }
}
